﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefEquipmentSerial" :model="stateEquipmentSerial.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_EquipmentId_FormItem" prop="Entity.EquipmentId" :label="$t('message.autotrans._Model_EquipmentSerial_Equipment')">
            <el-select v-model="stateEquipmentSerial.vmModel.Entity.EquipmentId" disabled clearable>
               <el-option v-for="item in stateEquipmentSerial.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_SerialName_FormItem" prop="Entity.SerialName" :label="$t('message.autotrans._Model_EquipmentSerial_SerialName')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_SerialName')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.SerialName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Description_FormItem" prop="Entity.Description" :label="$t('message.autotrans._Model_EquipmentSerial_Description')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_Description')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.Description" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_BaudRate_FormItem" prop="Entity.BaudRate" :label="$t('message.autotrans._Model_EquipmentSerial_BaudRate')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_BaudRate')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.BaudRate" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_DataLength_FormItem" prop="Entity.DataLength" :label="$t('message.autotrans._Model_EquipmentSerial_DataLength')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_DataLength')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.DataLength" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_StopBit_FormItem" prop="Entity.StopBit" :label="$t('message.autotrans._Model_EquipmentSerial_StopBit')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_StopBit')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.StopBit" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Parity_FormItem" prop="Entity.Parity" :label="$t('message.autotrans._Model_EquipmentSerial_Parity')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_Parity')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.Parity" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Threshold_FormItem" prop="Entity.Threshold" :label="$t('message.autotrans._Model_EquipmentSerial_Threshold')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_Threshold')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.Threshold" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Active_FormItem" prop="Entity.Active" :label="$t('message.autotrans._Model_EquipmentSerial_Active')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_Active')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.Active" disabled clearable></el-input>
        </el-form-item>

        </el-col>
<!--        <el-col :xs="24" :lg="24" class="mb20">-->
<!--        <el-form-item ref="Entity_TagId_FormItem" prop="Entity.TagId" :label="$t('message.autotrans._Model_EquipmentSerial_TagId')">-->
<!--            <el-input v-model="stateEquipmentSerial.vmModel.Entity.TagId" disabled clearable></el-input>-->
<!--        </el-form-item>-->

<!--        </el-col>-->
<!--        <el-col :xs="24" :lg="24" class="mb20">-->
<!--        <el-form-item ref="Entity_TagName_FormItem" prop="Entity.TagName" :label="$t('message.autotrans._Model_EquipmentSerial_TagName')">-->
<!--            <el-input v-model="stateEquipmentSerial.vmModel.Entity.TagName" disabled clearable></el-input>-->
<!--        </el-form-item>-->

<!--        </el-col>-->
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_GlobalPushlish_FormItem" prop="Entity.GlobalPushlish" :label="$t('message.autotrans._Model_EquipmentSerial_GlobalPushlish')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_GlobalPushlish')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.GlobalPushlish" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_CreateTime_FormItem" prop="Entity.CreateTime" :label="$t('message.autotrans._Model_EquipmentSerial_CreateTime')">
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.CreateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_UpdateTime_FormItem" prop="Entity.UpdateTime" :label="$t('message.autotrans._Model_EquipmentSerial_UpdateTime')">
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.UpdateTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_CreateBy_FormItem" prop="Entity.CreateBy" :label="$t('message.autotrans._Model_EquipmentSerial_CreateBy')">
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.CreateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_UpdateBy_FormItem" prop="Entity.UpdateBy" :label="$t('message.autotrans._Model_EquipmentSerial_UpdateBy')">
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.UpdateBy" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_IsValid_FormItem" prop="Entity.IsValid" :label="$t('message.autotrans._Model_EquipmentSerial_IsValid')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_EquipmentSerial_IsValid')}), trigger: 'blur' }]" >
            <el-input v-model="stateEquipmentSerial.vmModel.Entity.IsValid" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseEquipmentSerial"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentSerialDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentserialApi } from '/@/api/equipmentmanagement/equipmentserial';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefEquipmentSerial = ref();
const stateEquipmentSerial = reactive({
    vmModel: {
	  Entity:{
        EquipmentId: null,
        SerialName: '',
        Description: '',
        BaudRate: null,
        DataLength: null,
        StopBit: null,
        Parity: null,
        Threshold: null,
        Active: undefined,
        TagId: null,
        TagName: '',
        GlobalPushlish: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
        IsValid: undefined,
        ID:null,
      },

	},
    
    AllEquipments: [] as any[],
});

// 取消
const onCloseEquipmentSerial = () => {
    closeDialog();
};

// 提交
const onSubmitEquipmentSerial = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefEquipmentSerial.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            equipmentserialApi().edit(stateEquipmentSerial.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentSerial/GetEquipments',[],false).then(x=>{stateEquipmentSerial.AllEquipments = x});
    if (ci.attrs["wtmdata"]) {
		stateEquipmentSerial.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateEquipmentSerial.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	equipmentserialApi().get(stateEquipmentSerial.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateEquipmentSerial.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

